<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业4</title>
</head>

<body>
    <script>
        let randomNum = Math.floor(Math.random() * (50 - 10 + 1) + 10)
        let flag = true
        for (let i = 1; i <= 8; i++) {
            let num = prompt('请输入一个10~50之内的整数')
            if (num > randomNum) {
                alert('你猜大了，继续')
            } else if (num < randomNum) {
                alert('你猜小了，继续')
            } else {
                alert('恭喜你，猜对了~')
                flag = false
                break
            }
        }

        if (flag) {
            alert('阿欧~次数已经用完了')
        }
    </script>
</body>

</html>